<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script language="javascript" type="text/javascript">
        function isOver(sText, countfield, len) {
            var intlen = sText.value.length;
            if (intlen > len) {
                countfield.value = "最多可输入" + len.toString() + "个字符";
                alert("最多可输入" + len + "个字符");
                sText.focus();
                sText.select();
            } else {
                var str = "还可输入的字符数为";
                var str2 = sText.value;
                var len1 = 0;
                for (var i = 1; i <= intlen; i++) {
                    if (str2.charCodeAt(i) < 128)
                        len1++;
                    else
                        len1 += 2;
                }
                if (len1 > len) {
                    alert("最多可输入" + len + "个字符");
                } else {
                    var str1 = len - len1;
                    countfield.value = str.toString() + str1.toString();
                }
            }
        }
    </script>
</head>
<body>
<input id="Text1 " type="text" name="Text1" placeholder="最多输入100个字符"/><br/>
<input type="button" onkeydown="isOver(this,this.form.Text1,100)" value="查看还能输入的字符数">
</body>
</html>